<template>
  <div><page-list :x-uri="uri" :x-tabs="tabs" :custom-components="custom" :checkbox-item="false" /></div>
</template>

<script>
import PageList from '@public/template/page_list.vue';
import Price from './components/price.vue';
import Status from './components/status';

export default {
  components: {
    PageList
  },
  inject: ['reload'],
  data() {
    return {
      uri: '/admin/finance/split/flow/' + this.$route.params.user_id,
      tabs: [
        {
          title: '分成明细',
          uri: '/finance/split/list',
          meta: {
            permission: 'finance.split.list'
          }
        },
        {
          title: '用户分成',
          uri: '/finance/split/user',
          meta: {
            permission: 'finance.split.user'
          }
        },
        {
          title: '分成流水',
          uri: '/finance/split/flow/' + this.$route.params.user_id,
          meta: {
            permission: 'finance.split.flow'
          }
        }
      ],
      custom: {
        num: Price,
        amount: Price,
        frozen: Price,
        status: Status
      }
    };
  },
  methods: {
    update: function({ row }) {
      this.$router.push({ path: '/finance/split/' + row.order_no + '/fetch' });
    },
    delete: function({ row }) {
      this.$box
        .confirm('确认删除吗')
        .then(() => {
          this.$http.delete(
            '/admin/finance/split/' + row.id + '/delete',
            {},
            response => {
              this.$message.success(response.msg, _ => {
                this.reload();
              });
            },
            error => {
              this.$message.error(error.msg);
            }
          );
        })
        .catch(() => {});
    }
  }
};
</script>
